'''
    Message holding class
'''
import regexes

class message(object):
    def __init__(self, data, privmsg_dict, notice_dict):
        '''
            Return None if it's not a message, else return a wonderful object
            full of fun and interesting things
        '''
        self.private = False
        self.ok = True
        
        d = privmsg_dict
        if d is None:
            if notice_dict is None:
                self.ok = False
                return None
            else:
                d = notice
                self.notice = True
        
        if not len(d.keys()):
            self.ok = False
            return None
        
        for i in d:
            setattr(self, i, d[i])
        
        #if this is not being sent on a channel (i.e. it matches the nickname spec)
        #then set the channel to the PRIVMSG sender
        if regexes.nick.match(self.channel):
            self.channel = self.nick
            self.private = True
    
    def __repr__(self):
        return str(self.__dict__)
    def __str__(self):
        return str(self.__dict__)